/**
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 */
package com.jeesite.modules.kj.entity;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;

import com.jeesite.common.utils.excel.annotation.ExcelField;
import com.jeesite.common.utils.excel.annotation.ExcelFields;
import org.apache.poi.hpsf.Decimal;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.Date;
import com.jeesite.common.mybatis.annotation.JoinTable;
import com.jeesite.common.mybatis.annotation.JoinTable.Type;
import com.fasterxml.jackson.annotation.JsonFormat;

import com.jeesite.common.entity.DataEntity;
import com.jeesite.common.mybatis.annotation.Column;
import com.jeesite.common.mybatis.annotation.Table;
import com.jeesite.common.mybatis.mapper.query.QueryType;
import com.jeesite.common.utils.excel.annotation.ExcelField.Align;
/**
 * kj_integral_authEntity
 * @author hzy
 * @version 2021-07-13
 */
@Table(name="kj_integral_auth", alias="a", columns={
		@Column(name="id", attrName="id", label="id", isPK=true),
		@Column(name="service_name", attrName="serviceName", label="服务名", queryType=QueryType.LIKE),
		@Column(name="service_type", attrName="serviceType", label="服务类型"),
		@Column(name="total_hour", attrName="totalHour", label="服务时长"),
		@Column(name="service_time", attrName="serviceTime", label="服务时间"),
		@Column(name="address", attrName="address", label="详细地址"),
		@Column(name="description", attrName="description", label="服务介绍"),
		@Column(name="imgs", attrName="imgs", label="服务图片"),
		@Column(name="province", attrName="province", label="省"),
		@Column(name="city", attrName="city", label="市"),
		@Column(name="region", attrName="region", label="区"),
		@Column(name="country", attrName="country", label="国家"),
		@Column(name="approve_status", attrName="approveStatus", label="审核状态"),
		@Column(name="integrals", attrName="integrals", label="获得积分"),
		@Column(name="member_id", attrName="kjMember.id", label="用户id"),
		@Column(name="member_name", attrName="kjMember.name", label="用户名", queryType=QueryType.LIKE),
		@Column(name="approve_remarks", attrName="approveRemarks", label="审核备注", queryType=QueryType.LIKE),
		@Column(name="send_flag", attrName="sendFlag", label="积分发放状态"),
		@Column(name="job_type_id", attrName="jobTypeId", label="岗位类型ID"),
		@Column(name="job_type_name", attrName="jobTypeName", label="岗位类型名"),
		@Column(includeEntity=DataEntity.class),
	}, joinTable={
		@JoinTable(type=Type.LEFT_JOIN, entity= KjMember.class, alias="m",
				on="m.id = a.member_id",
				columns={
						@Column(name="id", attrName = "id"),
						@Column(name="name", attrName = "name", queryType=QueryType.LIKE),
						@Column(name="headimg", attrName = "headimg"),
						@Column(name="mobile", attrName = "mobile"),
						@Column(name="member_no", attrName = "memberNo")
				})
},
		orderBy="a.update_date DESC"
)
public class KjIntegralAuth extends DataEntity<KjIntegralAuth> {

	private static final long serialVersionUID = 1L;
	public static final String UNSEND = "0";
	public static final String SENDED = "1";
	public static final String PROCESSING = "0";
	public static final String OK = "1";
	public static final String REJECT = "2";
	private String serviceName;		// 服务名
	private String serviceType;		// 服务类型
	private BigDecimal totalHour;		// 服务时长
	private Date serviceTime;		// 服务时间
	private String address;		// 详细地址
	private String description;		// 服务介绍
	private String imgs;		// 服务图片
	private String province;		// 省
	private String city;		// 市
	private String region;		// 区
	private String country;		// 国家
	private String approveStatus;		// 审核状态
	private BigDecimal integrals;		// 获得积分
	private String approveRemarks;		// 审核备注
	private KjMember kjMember;
	private String sendFlag;
	private String jobTypeId;
	private String jobTypeName;

	private String fullAddress;

	public KjIntegralAuth() {
		this(null);
	}

	public KjIntegralAuth(String id){
		super(id);
	}



	@Valid
	@ExcelFields({
			@ExcelField(title="用户名", attrName="kjMember.name", align=Align.CENTER, sort=35),
			@ExcelField(title="中兴工号", attrName="kjMember.memberNo", align=Align.CENTER, sort=36),
			@ExcelField(title="电话", attrName="kjMember.mobile", align=Align.CENTER, sort=37),
			@ExcelField(title="服务名", attrName="serviceName", align= Align.CENTER, sort=50),
			@ExcelField(title="服务类型", attrName="serviceType", dictType = "service_type", align=Align.CENTER, sort=55),
			@ExcelField(title="服务时长", attrName="totalHour", align=Align.CENTER, sort=60),
			@ExcelField(title="服务时间", attrName="serviceTime", align=Align.CENTER, sort=65),
			@ExcelField(title="提交认证", attrName="createDate", align=Align.CENTER, sort=65),
			@ExcelField(title="省", attrName="province", align=Align.CENTER, sort=75),
			@ExcelField(title="市", attrName="city", sort=80, width = 25*256),
			@ExcelField(title="区", attrName="region", sort=81, width = 25*256),
			@ExcelField(title="详细地址", attrName="address", sort=82, width = 25*256),
			@ExcelField(title="审核状态", attrName="approveStatus", dictType = "approve_status", sort=83, width = 25*256),
			@ExcelField(title="服务介绍", attrName="description", align=Align.CENTER, sort=86),
			@ExcelField(title="岗位类型", attrName="jobTypeName", align=Align.CENTER, sort=87),
			@ExcelField(title="获得积分", attrName="integrals", align=Align.CENTER, sort=88),
			@ExcelField(title="提交时间", attrName="createDate", dataFormat="yyyy-MM-dd hh:mm", align=Align.CENTER, sort=99),
	})

	@NotBlank(message="服务名不能为空")
	@Length(min=0, max=255, message="服务名长度不能超过 255 个字符")
	public String getServiceName() {
		return serviceName;
	}

	public void setServiceName(String serviceName) {
		this.serviceName = serviceName;
	}

	@NotBlank(message="服务类型不能为空")
	@Length(min=0, max=255, message="服务类型长度不能超过 255 个字符")
	public String getServiceType() {
		return serviceType;
	}

	public void setServiceType(String serviceType) {
		this.serviceType = serviceType;
	}

	@NotNull(message="服务时长不能为空")
	public BigDecimal getTotalHour() {
		return totalHour;
	}

	public void setTotalHour(BigDecimal totalHour) {
		this.totalHour = totalHour;
	}

	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@NotNull(message="服务时间不能为空")
	public Date getServiceTime() {
		return serviceTime;
	}

	public void setServiceTime(Date serviceTime) {
		this.serviceTime = serviceTime;
	}

	@NotBlank(message="详细地址不能为空")
	@Length(min=0, max=255, message="详细地址长度不能超过 255 个字符")
	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getImgs() {
		return imgs;
	}

	public void setImgs(String imgs) {
		this.imgs = imgs;
	}

	@Length(min=0, max=255, message="省长度不能超过 255 个字符")
	public String getProvince() {
		return province;
	}

	public void setProvince(String province) {
		this.province = province;
	}

	@Length(min=0, max=255, message="市长度不能超过 255 个字符")
	public String getCity() {
		return city;
	}

	public void setCity(String city) {
		this.city = city;
	}

	@Length(min=0, max=255, message="区长度不能超过 255 个字符")
	public String getRegion() {
		return region;
	}

	public void setRegion(String region) {
		this.region = region;
	}

	@Length(min=0, max=255, message="国家长度不能超过 255 个字符")
	public String getCountry() {
		return country;
	}

	public void setCountry(String country) {
		this.country = country;
	}

	@Length(min=0, max=255, message="审核状态长度不能超过 255 个字符")
	public String getApproveStatus() {
		return approveStatus;
	}

	public void setApproveStatus(String approveStatus) {
		this.approveStatus = approveStatus;
	}

	public BigDecimal getIntegrals() {
		return integrals;
	}

	public void setIntegrals(BigDecimal integrals) {
		this.integrals = integrals;
	}

	@Length(min=0, max=255, message="审核备注长度不能超过 255 个字符")
	public String getApproveRemarks() {
		return approveRemarks;
	}

	public void setApproveRemarks(String approveRemarks) {
		this.approveRemarks = approveRemarks;
	}

	public KjMember getKjMember() {
		return kjMember;
	}

	public void setKjMember(KjMember kjMember) {
		this.kjMember = kjMember;
	}

	public String getSendFlag() {
		return sendFlag;
	}

	public void setSendFlag(String sendFlag) {
		this.sendFlag = sendFlag;
	}

	public String getJobTypeId() {
		return jobTypeId;
	}

	public void setJobTypeId(String jobTypeId) {
		this.jobTypeId = jobTypeId;
	}

	public String getJobTypeName() {
		return jobTypeName;
	}

	public void setJobTypeName(String jobTypeName) {
		this.jobTypeName = jobTypeName;
	}

	public String getFullAddress() {
		return nullStr(this.getProvince()) + nullStr(this.getCity()) + nullStr(this.getCountry()) + nullStr(this.getAddress());
	}

	private String nullStr(String str){
		if(str == null){
			return "";
		}
		return str;
	}

	public void setFullAddress(String fullAddress) {
		getSqlMap().getWhere().andBracket("province", QueryType.LIKE, fullAddress)
				.or("city", QueryType.LIKE, fullAddress)
				.or("country", QueryType.LIKE, fullAddress)
		.or("address", QueryType.LIKE, fullAddress).endBracket();
	}
}
